<template>
    <div>
        <p>书名：<input type="text" v-model="name"></p>
        <p>价格：<input type="text" v-model="price"></p>
        <p>封面：<input type="file"></p>
        <select v-model="ssa">
            <option :value="i.id" v-for="(i,j) in authlist" :key="j">{{i.name}}</option>
        </select>
        <p><input type="button" @click="bookcreate()" value="添加"></p>
    </div>
</template>

<script>
import axios from 'axios'
import {RI_AU_show,RI_BK_create} from '../axios_send/api.js'
export default {
    name:"BKbook",
    data(){
        return{
            name:"",
            price:"",
            file:"",
            authlist:"",
            ssa:""
        }
    },
    created(){
        this.auths()
    },
    methods:{
        auths(){
            RI_AU_show()
            .then(res=>{
                console.log(res)
                this.authlist = res
            })
        },
        bookcreate(){
            var form_data = new FormData()
            form_data.append("name",this.name)
            form_data.append("price",this.price)
            form_data.append("img",this.file)
            form_data.append("ssa",this.ssa)
            axios({
                url:"http://127.0.0.1:8000/zks/BKbook/",
                method:"post",
                data:form_data
            })
            // var data = {
            //     "name":this.name,
            //     "price":this.price,
            //     "img":this.file,
            //     "author_id":this.ssa
            //     }
            // RI_BK_create(data)
            .then(res=>{
                console.log(res)
            })
        }
    }
}
</script>

<style>

</style>
